import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Radar
from pyecharts.globals import ThemeType
#读取数据，并将第1列数据指定为行标签
df=pd.read_excel('服装销售数据.xlsx',index_col=0)
radar=Radar(init_opts=opts.InitOpts(
    width='600px', height='400px',
    theme=ThemeType.ROMANTIC, page_title='雷达图'))
radar.add(df.columns[0],[df['针织衫'].tolist()], color='purple',
          label_opts=opts.LabelOpts(is_show=False))
radar.add(df.columns[1],[df['卫衣'].tolist()], color='blue',
          label_opts=opts.LabelOpts(is_show=False))
radar.add(df.columns[2],[df['连衣裙'].tolist()], color='green',
          label_opts=opts.LabelOpts(is_show=False))
#设置雷达图配置项
radar.add_schema(
    schema=[
        opts.RadarIndicatorItem(name='新世界店',max_=52000),
        opts.RadarIndicatorItem(name='万科店',max_=52000),
        opts.RadarIndicatorItem(name='南京路店',max_=52000),
        opts.RadarIndicatorItem(name='滨江道店',max_=52000),
        opts.RadarIndicatorItem(name='和平路店', max_=52000),
    ],
    shape='circle',
    center=['50%','60%'],
    splitline_opt=opts.SplitLineOpts(is_show=True,
                                     linestyle_opts=opts.LineStyleOpts(color='grey')),
    #设置文本样式
    textstyle_opts=opts.TextStyleOpts(color='black'),
)
#设置全局配置项
radar.set_global_opts(
    #设置标题配置项
    title_opts=opts.TitleOpts(
        title='各类服装在不同门店的销售额雷达图',
        pos_left='center'),
    #设置图例配置项
    legend_opts=opts.LegendOpts(pos_right='5%',pos_top='10%')
)
radar.render('radar_sale.html')     #渲染图表
